﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

/// <summary>
/// Summary description for terminateBLL
/// </summary>
public class TerminateBLL
{
    TerminateDAL dal = new TerminateDAL();
    AccountsManager am = new AccountsManager();

	public TerminateBLL()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public void terminatePolicy(int insuredID, String termianteReason,String savingAccountNo)
    {
        DateTime startDate = dal.getStartDate(insuredID);
        dal.terminate(insuredID, termianteReason);

        if (DateTime.Now.AddDays(-14).CompareTo(startDate) <= 0)
        {
            Hashtable ht = dal.getInsuranceAccountNo(insuredID);
            String insuranceAccountNo = ht["accountNo"] as String;
            Decimal refundPremium = (Decimal)ht["premium"];
          
            am.transferFromInsuranceToSaving(insuranceAccountNo,savingAccountNo,refundPremium);
           
        }

         
    }
}